<!DOCTYPE html>
<html xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include/src :: form_base_js_and_css"/>
</head>
<body style="background-color: #f2f2f2; height: 100%;">

	<div id="id_panel">
	</div>
	<script th:inline="javascript">
		var canvassApplyItemId = '[(${detail.canvassApplyItemId})]';
		var businesslicense = '[(${detail.businesslicense})]';
		var cooperateAgreement = '[(${detail.cooperateAgreement})]';
		var investType = '[(${detail.investType})]';

	// 表单初始化
	var formObj = null;
	//使用layui的sku模块
	layui.config({
	    //自定义layui组件的目录,设定扩展的layui模块的所在目录，一般用于外部模块扩展
	    base: '/static/js/layui_extends/',
		version: true
	}).use(['form', 'jquery', 'laydate', 'YsForm', 'YsModal'], function(){
		var $ = layui.jquery,
		form = layui.form,
				laydate = layui.laydate,
				YsForm = layui.YsForm,
				YsModal = layui.YsModal
		/* 
		* 表单初始化
		* 参数1：表单配置参数
		* 参数2：子表配置参数
		*/
		formObj = YsForm.init(
		{
			id:'id_panel', // 页面容器ID
			dto: $.parseJSON(JSON.stringify([[${dto}]]))
		}
		);

		//营业执照附件按钮
		var str = ``
				+ `<div class="layui-inline layui-col-xs4 margin_r_0">`
				+ `<label class="layui-form-label padding_6_0 width_160 margin_0_0_0_N10">营业执照：</label>`
				+ `<div class="layui-input-block margin_l_150 min_height_38">`
				+ `<input type="text" name="businesslicense" id="businesslicense" value=" `+(businesslicense!=undefined&&businesslicense!=null?businesslicense:'0个附件')+`" autocomplete="off"`
				+ ` class="layui-input height_30 height_30 cannot_edit" readonly data-filter="_filter_input_file_multy" data-source-code="businesslicense" data-source-type="22" data-source-id="`+canvassApplyItemId+`">`
				+ `</div>`
				+ `</div>`;

		//合作协议附件按钮
		var str1 = ``
				+ `<div class="layui-inline layui-col-xs4 margin_r_0">`
				+ `<label class="layui-form-label padding_6_0 width_160 margin_0_0_0_N10">合作协议：</label>`
				+ `<div class="layui-input-block margin_l_150 min_height_38">`
				+ `<input type="text" name="cooperateAgreement" id="cooperateAgreement" value="`+(cooperateAgreement!=undefined&&cooperateAgreement!=null?cooperateAgreement:'0个附件')+`" autocomplete="off"`
				+ ` class="layui-input height_30 height_30 cannot_edit" readonly data-filter="_filter_input_file_multy" data-source-code="cooperateAgreement" data-source-type="23" data-source-id="`+canvassApplyItemId+`">`
				+ `</div>`
				+ `</div>`;

		//$('#' + formObj.c.id_form).find('.layui-form-item').append(str);
		//$('#' + formObj.c.id_form).find('.layui-form-item').append(str);

		formObj.afterFormElement(27,str1);
		formObj.afterFormElement(27,str);

		//招商类型
		var str2 = ``
				+ `<div class="layui-inline layui-col-xs4 margin_r_0">`
				+ `<label class="layui-form-label padding_6_0 width_160 margin_0_0_0_N10">招商类型：</label>`
				+ `<div class="layui-input-block margin_l_150 min_height_38">`
				+ `<input type="text" id="investTypeTxt" name="investTypeTxt" value="" autocomplete="off" class="layui-input height_30 height_30 cannot_edit" disabled>`
				+ `</div>`
				+ `</div>`;

		formObj.afterFormElement(5,str2);

		var listOption = formObj.c.dict["InvestType"];
		for(var j=0;j<listOption.length;j++){
			var option = listOption[j];
			if(investType == option.value){
				$('#investTypeTxt').val(option.name);
			}
		}


		//监听设置
		//先移除监听、再添加监听
		$('#' + formObj.c.id).find('input[data-filter="_filter_input_file_multy"]').off("click");
		formObj.listenFormOfFileMulty();

		// 弹出框框回调函数
		formObj.matchValuesAfterModalSelectRadio = function (colCode, rowSelected, extraData) { // 单选框选中数据后，匹配表单数值
			var t = formObj;
			var domForm = $('#' + t.c.id_form);
			for(var i = 0; i < t.c.dto.rows.length; i++){
				var col = t.c.dto.rows[i];
				if (col.code == colCode) {
					// 给选择框设置的字段赋值
					domForm.find('input[name="' + colCode + '"]').val(rowSelected[col.modalValueCode]);
				} else if(col.modalRelativeCode == colCode) {
					domForm.find('input[name="' + col.code + '"]').val(rowSelected[col.modalValueCode]);
				}
			}

			if(colCode=='pbid'){
				$('#businesslicense').val(rowSelected.businesslicense);
				$('#businesslicense').attr('data-source-type',22);
				$('#businesslicense').attr('data-source-id',rowSelected.id);
				$('#cooperateAgreement').val(rowSelected.businesslicense);
				$('#cooperateAgreement').attr('data-source-type',23);
				$('#cooperateAgreement').attr('data-source-id',rowSelected.id);

				/*
				var listOption = t.c.dict["InvestType"];
				for(var j=0;j<listOption.length;j++){
					var option = listOption[j];
					if(rowSelected.investType == option.value){
						$('#investTypeTxt').val(option.name);
					}
				}

				 */
				if(rowSelected.investType == 0){
					$('#investTypeTxt').val('首店');
				}else if(rowSelected.investType == 1){
					$('#investTypeTxt').val('次店');
				}else if(rowSelected.investType == 2){
					$('#investTypeTxt').val('特殊店');
				}else {
					$('#investTypeTxt').val('');
				}
				//先移除监听、再添加监听
				$('#' + formObj.c.id).find('input[data-filter="_filter_input_file_multy"]').off("click");
				formObj.listenFormOfFileMulty();
			}


		}


	});

	</script>

</body>
</html>
